<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>图标上传</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    
    <!-- 在引入goouploader-init.js之前还需要先引入jquery，否则在IE下会报jQuery未定义 -->
    <script type="text/javascript" src="rp/scripts/goouploader/codebase/jquery-1.3.2.min.js"></script>
    <!-- goouploader-init.js的引入必须在miniui的JS引入之前，否则miniui将无法正常工作 -->
    <script src="rp/scripts/goouploader/goouploader-init.js" type="text/javascript"></script>
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	
  </head>
  
  <body class="body-fit">
  	
  	<div style="width:100%;">
        <div class="mini-toolbar" style="padding:0px;border-top:0;border-left:0;border-right:0;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                       <a class="mini-button" onclick="openEditIconsCssFileWindow()">编辑服务器上的icons.css文件</a>
                       <a class="mini-button" onclick="">编辑开发环境上的icons.css文件</a>
                    </td>
                    <td style="white-space:nowrap;">
                    	
                    </td>
                </tr>
            </table>           
        </div>
    </div>
  	
  	<div style="padding: 5px;">
	  	<form id="form1">
	  		<fieldset>
	  			<legend>友情提示</legend>
	  			<span style="color: red;">
	  				注意：强烈建议一次只上传单个图标文件，否则会出现一个class名对应多个图片的情况
	  			</span>
	  			<br/>
	  			<span style="color: green;">
	  				支持的图片类型为：JPG、PNG；上传的图片大小推荐：16px*16px；
	  			</span>
	  		</fieldset>
	  		<table>
	  			<tr>
	  				<td>class名称：</td>
	  				<td>
	  					<input id="className" class="mini-textbox" required="true" emptyText="推荐格式：icon-xxx；示例：icon-add" style="width: 250px;"/>
	  				</td>
	  			</tr>
	  			<tr>
	  				<td>服务器存放目录：</td>
	  				<td>
	  					<input id="iconsSaveDir" class="mini-textbox" emptyText="" 
	  						style="width: 600px;" value="" enabled="false"/>
	  				</td>
	  			</tr>
	  			<!-- <tr>
	  				<td>是否上传至开发环境：</td>
	  				<td>
	  					<div id="rbl" class="mini-radiobuttonlist" repeatItems="2" repeatLayout="none" repeatDirection="horizontal"
						    textField="text" valueField="id" value="0" data="YesOrNo">
						</div>
	  				</td>
	  			</tr> -->
	  			<tr>
	  				<td>开发环境图标存放目录:</td>
	  				<td>
	  					<input id="iconsSaveDevelopDir" class="mini-textbox" emptyText="" 
	  						style="width: 600px;" value="" enabled="true"/>
	  				</td>
	  			</tr>
	  			<tr>
	  				<td>开发环境icons.css文件路径：</td>
	  				<td>
	  					<input id="iconsCssSaveDevelopPath" class="mini-textbox" emptyText="" 
	  						style="width: 600px;" value="" enabled="true"/>
	  				</td>
	  			</tr>
	  			<tr>
	  				<td valign="top">上传图标：</td>
	  				<td>
	  					<div id="uploaderDiv" style="display: block;"></div>
	  				</td>
	  			</tr>
	  			<tr>
	  				<td></td>
	  				<td>
	  					<a id="uploadTomcatBtn" class="mini-button" iconCls="icon-upload" onclick="gooupload()">上传</a>
	  				</td>
	  			</tr>
	  		</table>
	  	</form>
  	</div>
  	
  	<script type="text/javascript">
  		var uploaderDiv;
  		var iconsCssWebServerDirPath;
  		
  		$(function(){
  			
  			/*var rbl = mini.get("rbl");
  		    rbl.on("valuechanged", function (e) {
  		        if(this.getValue() == "1"){
  		        	$("#iconsSaveDevelopDir").attr("enabled","true");
  		        }
  		    });*/
			
			rp_ajax("rp/system/common/getWebTomcatPath",{},function(text){
				
				webSaveDirPath = text+"\\rp\\scripts\\miniui\\themes\\icons\\";
				iconsCssWebServerDirPath = text+"\\rp\\scripts\\miniui\\themes\\icons.css";
				mini.get("iconsSaveDir").setValue(webSaveDirPath);
				
				/*
		    		注意：这些参数都不能删除，否则将无法正常上传文件
		    		saveToDb：是否需要将上传的文件信息保存至数据库，默认保存
		    		webSaveDirPath: 保存上传文件的目录路径，如果为0，则使用平台配置默认保存路径
		    		fileRename：是否在后台对文件进行重命名，默认为true
		    		customOperaImpl：是否需要执行自定义操作，默认不执行，如果需要执行，需要传入实现类Bean的名称
		    		entityName：上传文件对应的实体类名
		    		entityId：上传文件对应的实体类ID
	    	 	*/
				var params = {
		    				"saveToDb":"false",
		    				"webSaveDirPath":webSaveDirPath,
		    				"fileRename":"false",
		    				"customOperaImpl":"uploadIconCustomOpera",
		    				"entityName":"",
		    				"entityId":""};
				
				var property={ 
		    		width:600,
		    		height:180,
		    		multiple:true,
		    	    file_types:"*.jpg;*.png",
		    	    file_types_description: "支持上传的文件格式",
		    	    post_params:params,
		    	    btn_add_text:"添加",
		    	    btn_up_text:"上传",
		    	    btn_cancel_text:"放弃",
		    	    btn_clean_text:"清空",
		    	    op_del_text:"单项删除",
		    	    op_up_text:"单项上传",
		    	    op_fail_text:"上传失败",
		    	    op_ok_text:"上传成功",
		    	    op_no_text:"取消上传",
		    	 	file_size_limit: 0,
					file_upload_limit: 0,
					file_queue_limit: 0,
		    		upload_url:"<%= basePath %>/servlet/goouploadFile"
		    	};
				
				uploaderDiv = jq132.createGooUploader($("#uploaderDiv"),property);
			});
			
		});
	  	
	   	function gooupload(){
	   		//表单必填字段校验
			var form = new mini.Form("#form1");
			form.validate();
            if (form.isValid() == false) return;
            
			uploaderDiv.$swfUpload.addPostParam("className",mini.get("className").getValue());
			uploaderDiv.$swfUpload.addPostParam("iconsCssWebServerDirPath",iconsCssWebServerDirPath);
			uploaderDiv.$swfUpload.addPostParam("iconsSaveDevelopDir",mini.get("iconsSaveDevelopDir").getValue());
			uploaderDiv.$swfUpload.addPostParam("iconsCssSaveDevelopPath",mini.get("iconsCssSaveDevelopPath").getValue());
	   		uploaderDiv.$btn_upload.click();
	   	}
	   	
	   	function openEditIconsCssFileWindow(){
	   		mini.open({
                url: "rp/system/baseData/iconMng/editIconsCssFile.jsp",
                title: "编辑icons.css文件", 
                width: 1024, 
                height: 560,
                showMaxButton: true,
                onload: function () {
                	
                },
                ondestroy: function (action) {
					
                }
            });
	   	}
	</script>
	
  </body>
</html>
